package cn.ecut.service.impl;

import cn.ecut.dao.PuweiDao;
import cn.ecut.model.Fangjian;
import cn.ecut.model.Puwei;
import cn.ecut.service.PuweiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.DecimalFormat;
import java.util.List;

@Service
public class PuweiServiceimpl implements PuweiService {
    @Autowired
    private PuweiDao puweiDao;

    @Override
    public List<Puwei> selectAll() {
        return puweiDao.selectAll();
    }

    @Override
    public int selectAllcount() {
        return puweiDao.selectAllcount();
    }

    @Override
    public List<Puwei> advanceSelect(String s) {
        return puweiDao.advanceSelect(s);
    }

    @Override
    public String selectThelast() {
        return puweiDao.selectThelast();
    }

    @Override
    public int updateQiyong(Puwei puwei) {
        return puweiDao.updateQiyong(puwei);
    }

    @Override
    public String getpuweiBianhao() {
        DecimalFormat decimalFormat=new DecimalFormat("00000");
        String s = puweiDao.selectThelast();
        s=s.substring(2);
        System.out.println(s);
        int i=Integer.parseInt(s)+1;
        String k=decimalFormat.format(i);
        String puweiBianhao = "PW"+k;
        System.out.println(puweiBianhao);
        return puweiBianhao;
    }

    @Override
    public Fangjian selectFangjian(String fangjianbianma) {
        return puweiDao.selectFangjian(fangjianbianma);
    }

    @Override
    public int insert(Puwei puwei) {
        return puweiDao.insert(puwei);
    }

    @Override
    public int selectAllcountPuwei(String fangjianbianma) {
        return puweiDao.selectAllcountPuwei(fangjianbianma);
    }

    @Override
    public int deleteByPrimaryKey(String puweibianhao) {
        return puweiDao.deleteByPrimaryKey(puweibianhao);
    }

    @Override
    public List<Fangjian> selectAllfangjian() {
        return puweiDao.selectAllfangjian();
    }

    @Override
    public int updateByPrimaryKey(Puwei puwei) {
        return puweiDao.updateByPrimaryKey(puwei);
    }

    @Override
    public int updateShifouyoupuwei(Fangjian fangjian) {
        return puweiDao.updateShifouyoupuwei(fangjian);
    }

    @Override
    public String selectFangjianbianma(String puweibianhao) {
        return puweiDao.selectFangjianbianma(puweibianhao);
    }

    @Override
    public int updateShiyongzhuangtai(Fangjian fangjianbian) {
        return puweiDao.updateShiyongzhuangtai(fangjianbian);
    }

}
